﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using jQueryDemo.DataAccess.DataSet.ServiceCategoryTableAdapters;
using System.Data;

namespace jQueryDemo.BusinessObject.Entity
{
    public class ServiceCategory : BusinessObjectBase
    {
        #region Properties
        public string Name { get; set; }
        public string Code { get; set; }
        [ReflectionIgnored]
        public Service[] Services { get; set; }
        [ReflectionIgnored]
        public int BranchId { get; set; }
        [ReflectionIgnored]
        public int DomainId { get; set; }
        #endregion

        #region Fields
        private ServiceCategoryTableAdapter TableAdapter
        {
            get { return new ServiceCategoryTableAdapter(); }
        }
        #endregion
        public override void Load()
        {
            throw new NotImplementedException();
        }
        public override void Insert()
        {
            throw new NotImplementedException();
        }
        public override void Update()
        {
            throw new NotImplementedException();
        }
        public override void Delete()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Load all available service categories
        /// </summary>
        /// <returns></returns>
        public ServiceCategory[] LoadAll()
        {
            List<ServiceCategory> allCategories = new List<ServiceCategory>();
            int? branchId = null;
            if (BranchId > 0) branchId = BranchId;
            int? domainId = null;
            if (DomainId > 0) domainId = DomainId;
            DataTable dtCategories = TableAdapter.GetAllServiceCategories(branchId, domainId);
            foreach (DataRow row in dtCategories.Rows)
            {
                ServiceCategory svc = new ServiceCategory();
                svc.LoadRow(row);
                allCategories.Add(svc);
            }
            return allCategories.ToArray();
        }
    }
}
